package com.isunland.managesystem.adapter;

import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseButterKnifeAdapter;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.ProjectCollectOriginal.ProjectCollectContent;
import com.isunland.managesystem.utils.MyStringUtil;
import java.util.ArrayList;

public class ProjectInfoListAdapter extends BaseButterKnifeAdapter<ProjectCollectContent> {

  public ProjectInfoListAdapter(BaseVolleyActivity context,
      ArrayList<ProjectCollectContent> objects) {
    super(context, objects);
  }

  @Override public boolean isEmpty() {

    return false;
  }

  @Override protected int setLayoutId() {
    return R.layout.adapter_customer_back;
  }

  @NonNull @Override protected BaseViewHolder initHolder(View convertView) {
    return new ViewHolder(convertView);
  }

  @Override
  protected void initView(ProjectCollectContent item, BaseViewHolder baseHolder, int position) {
    ViewHolder holder = (ViewHolder) baseHolder;
    holder.tvStatus.setVisibility(View.GONE);
    holder.ivLogo.setImageResource(R.drawable.xiangmutaizhang);
    holder.tvTitle.setText(item.getProjectName());
    holder.tvContent.setText(item.getPartaName());
    holder.tvContent.setVisibility(
        TextUtils.isEmpty(item.getPartaName()) ? View.GONE : View.VISIBLE);
    holder.tvBottom.setText(MyStringUtil.connect(item.getPmName(), " | ", item.getRegDate()));
  }

  protected class ViewHolder extends BaseViewHolder {
    @BindView(R.id.iv_logo) ImageView ivLogo;
    @BindView(R.id.tv_title) TextView tvTitle;
    @BindView(R.id.tv_status) TextView tvStatus;
    @BindView(R.id.tv_content) TextView tvContent;
    @BindView(R.id.tv_bottom) TextView tvBottom;

    ViewHolder(View view) {
      super(view);
      ButterKnife.bind(this, view);
    }
  }
}
